-- This script describes the structure of a hypercard stack
--
on mouseUp
-- initialize
global userName,showScripts, showEvents, analysis, theScripts
-- unsetLocks
set lockScreen to false
set lockMessages to false
set lockRecent to false
--
--put empty into card field 1
put empty into user
-- get name of stack
if userName is not empty then put ", " &word 1 of username into user
ask "Analyze what stack" &user &"?" with the short name of this stack
-- proceed if user gives name
if it is not empty then
put it into theStack
-- offer choces in report
put theStack&".hc" into theFile
ask "Save analysis to file named?" with theFile
if it is not empty then put it into theFile
answer "Do message tracking?" with "Yes" or "No"
put (it="Yes") into showEvents
answer "Do script extraction?" with "Yes" or "No"
put (it="Yes") into showScripts
-- the report wwill be built in a container called analysis
-- start building with title
if user is not empty then put " for " &userName into user
put "Analysis of " &theStack &" stack " &user into analysis
if showEvents or showScripts then put " with" after analysis
if showEvents then put " message tracking" after analysis
if showEvents and showScripts then put " and" after analysis
if showScripts then put " script extraction" after analysis
put return &return after analysis
-- do som inits
setLocks true
-- now analyze stack
analyze theStack,0
-- now unlock
setLocks false
-- display & cleanup
put "Writing analysis to file "&theFile into message box
open file theFile
write analysis &theScripts &return &"End of analysis" to file theFile
put empty into analysis
put empty into theScripts
hide message box
end if
end mouseUp
--
-- this handler is invoked by message setLockws
on setLocks flag
-- locking keeps this stack in control
if flag then set cursor to 4 else pop card
if flag then set lockScreen to true else set lockScreen to false
if flag then set lockMessages to true else set lockMessages to false
if flag then set lockRecent to true else set lockRecent to false
if flag then push this card else set cursor to 1
end setlocks
--
-- this handler does analysis
-- uses recursion to dig through stack
on analyze thing,lev
-- analyze a stack,back,card,fld or button
global analysis,showScripts,ShowEvents,theScripts
put the name of thing into itsName
-- skip self
if itsName contains "Analyze Stack" then exit analyze
-- give user some feedback
put "Now examining " &itsName
-- report the object
put indent(lev) &itsName &return after analysis
if lev < 2 then go to thing
put word 1 of itsName into object
-- determine what kind of components
if object="stack" then put "bkgnd,card" into sub
if object="bkgnd" or object="card" then put object &" field," &object &" button" into sub
-- if it's a card, say backgnd
if object="card" and lev=1 then
put indent(lev) &" of" after analysis
put the name of this bkgnd &return after analysis
end if
-- if user asked for scripts...
if showScripts then
put the script of thing into itsScript
if itsScript is not empty then
put return &"ΓÇó===ΓÇó===ΓÇó Script of " &itsName &return after theScripts
put itsScript &return after theScripts
put return &"Γêå===Γêå===Γêå" & return after theScripts
end if
end if
-- bug after this ....
-- if the user asked for message tracking...
if showEvents then
put the script of thing into itsScript
put the number of lines of itsScript into nlines
if nlines > 2 then
-- this takes time..
put "Now examining the script of " &itsName
put indent(lev) &"- handles these message(s):" &return after analysis
-- examine each line
repeat with i=1 to nlines
put line i of itsScript into linei
put word 1 of linei into word1
-- the word "on" signals handler
if (word1="on") then put indent(lev) &" " &(word 2 of linei) &return after analysis
-- words "pass" and "send" signal deviations
if (word1="pass") then put indent(lev) &" (which it passes)" &return after analysis
if (word1="send") then put indent(lev) &" (It sends message " &(word 2 of linei) &" to " &(word 4 of linei) &" )" &return after analysis
end repeat
end if
end if
-- determine what components object has
if lev<2 then
do "put the number of " &(item 1 of sub) &"s into n1"
do "put the number of " &(item 2 of sub) &"s into n2"
if n1<>1 then put "s" into s1 else put "" into s1
if n2<>1 then put "s" into s2 else put "" into s2
-- report components
if n1+n2>0 then
put indent(lev) &" contains " &n1 &" " &(item 1 of sub) after analysis
put s1 &" and " &n2 &" " &(item 2 of sub) &s2 &return after analysis
-- then for each kind..
repeat with i=1 to 2
do "put the number of " &(item i of sub) &"s into n"
-- and for each component...
repeat with j=1 to n
put (item i of sub) &" " &j into m
-- analyze IT
analyze m,lev+1
end repeat
end repeat
end if
end if
end analyze
--
function indent level
-- this produces a tab for indentation of recursion
repeat with i=1 to level+1
put " " after s -- 2 spaces
end repeat
return(s)
end indent
-- part contents for background part 6
----- text -----
NOTES ON THIS HYPERCARD IMPLEMENTATION OF TREE DRAWING.
THE EXAMPLE TREES
The 5S rRNA tree descriptions are taken from a haphazard (= random) selection of 27 of the 5.8S rRNA sequences stored in the Structural RNA section of GenBank. These sequences were aligned with the Clustal multiple alignment program, which also produces a tree description based on pairwise similarities of the aligned sequences. This is where the Clustal tree came from. Then the aligned sequences were fed into DNAML from the Phylip package. This resulted in another, noticeably different tree. I have no comments on which is the "correct" or better tree.
The Clustal tree description uses _cumulative node lengths_, rather than the internode lengths expected in the standard tree description described earlier, and used by the current DrawTree and DrawGram. If I find the time, I'll change these to internode lengths before sending out. If not, you will need to change them for meaningful use of the node lengths.
PLOT OUTPUT
The plots are drawn in a separate card-sized window, and a second, full 8x11" page, plot is drawn but not displayed. You are provided with a selection of function buttons: clip, print, file, and such. The print and file buttons use the full 8x11 page plot. You will want to choose landscape drawing mode (11x8 page) for these to fit on one page. The plot file that is produced is a standard Mac PICT file, which you can edit with MacDraw II, SuperPaint, Canvas or other Mac object graphics editors. Many of the plotgram and plotree options were not implemented as it is easier to get these trees to look the way you want with a graphics editor.
Note: Your Mac must have installed the TIMES font, point sizes 9 and 12, to display the labels in these drawings properly. 9 point is used in the cardsized window, and 12 point on the full page file.
The clip button copies the card-sized drawing to hypercard, and leaves it on the clipboard where you can paste it into another program. Note that the plots are all in Quickdraw's vector/object graphics, but when clipped to a hypercard, it becomes bitmapped graphics (which cannot be resized or editted).
Also, these routines will commonly draw labels at any rotation they or you think are best. However, the labels are displayed in the card window only with rotations of 0┬░, 90┬░, 180┬░ or 270┬░, as I haven't yet written a routine to draw text at all angles. The true angle of rotation is stored in the drawing for use by the printer or drawing editor. Rotated text will be displayed and manipulable by most of the professional Mac drawing programs. I favor MacDraw II for editting these files. You can select your prefered drawing program for the PICTure files that the hp2pict routine creates by editting the Hypercard script of the plot background. There all of the routines which call the hp2pict XCMD are located, and the routine called "FilePict" lets you set the file creator of the resulting Mac PICTure. "MDPL" is the MacDraw II signature, "SPNT" is for SuperPaint, "MDRW" is for MacDraw.
The plotgram and plotree (and now drawgram and drawtree) programs as originally written produce a set of plot commands for various hardware. It proved too time consuming for me to insert the Mac quickdraw plot commands directly into these programs (many hassles with drawing frames of reference, and 1 wasted day), but I adapted an hp2pict translator from other uses fairly easily. New versions of plotgram / plotree may be adapted to this deck by following the comments in the source included here.